/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tracker.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *Workshop 
 *Class ID        : SE0691   
 *Student ID      : SE90009
 *Student Name    : Phạm Nguyễn Nhật Trung
 *Due Date        : 12 November 2012
 *I declare that this assignment is my own work
 *in accordance with FPT Policy.
 */
@Entity
@Table(name = "Points")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PointsEntity.findAll", query = "SELECT p FROM PointsEntity p"),
    @NamedQuery(name = "PointsEntity.findById", query = "SELECT p FROM PointsEntity p WHERE p.id = :id"),
    @NamedQuery(name = "PointsEntity.findByTorrentType", query = "SELECT p FROM PointsEntity p WHERE p.torrentType = :torrentType"),
    @NamedQuery(name = "PointsEntity.findByPoint", query = "SELECT p FROM PointsEntity p WHERE p.point = :point")})
public class PointsEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Column(name = "TorrentType")
    private Integer torrentType;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Point")
    private Float point;
    @JoinColumn(name = "UserId", referencedColumnName = "UserId")
    @ManyToOne(optional = false)
    private UsersEntity userId;
    @JoinColumn(name = "TorrentId", referencedColumnName = "TorrentId")
    @ManyToOne(optional = false)
    private TorrentsEntity torrentId;

    public PointsEntity() {
    }

    public PointsEntity(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getTorrentType() {
        return torrentType;
    }

    public void setTorrentType(Integer torrentType) {
        this.torrentType = torrentType;
    }

    public Float getPoint() {
        return point;
    }

    public void setPoint(Float point) {
        this.point = point;
    }

    public UsersEntity getUserId() {
        return userId;
    }

    public void setUserId(UsersEntity userId) {
        this.userId = userId;
    }

    public TorrentsEntity getTorrentId() {
        return torrentId;
    }

    public void setTorrentId(TorrentsEntity torrentId) {
        this.torrentId = torrentId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PointsEntity)) {
            return false;
        }
        PointsEntity other = (PointsEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tracker.entity.PointsEntity[ id=" + id + " ]";
    }

}
